import { defineStore } from "pinia";
import Cookies from "js-cookie";

// const cookiesStorage: any = {
//   // setItem(key: string, state: any) {
//   //   return Cookies.set(key, state.accessToken, { expires: 3 });
//   // },
//   // getItem(key: string) {
//   //   return JSON.stringify({ accessToken: Cookies.get(key) });
//   // },
// };

let storeHome = defineStore("home", {
  persist: {
    enabled: true,
    strategies: [
      {
        storage: sessionStorage,
        paths: ["curHome"],
      },
      // {
      //   key: "practiveToken", //如果使用cookie存储，必须加上key，否则value值是undefined
      //   storage: cookiesStorage,
      //   paths: ["practiveToken"],
      // },
    ],
  },

  state: () => {
    return {
      curHome: 0,

      // practiveToken: "practiveToken666",
    };
  },
  getters: {},
  actions: {
    updateHome(state: object) {
      console.log(state, "state");
    },
  },
});
export default storeHome;
